/**
 * 〈功能简述〉<br>
 * 〈MD5密码加密〉
 *
 * @author LiJunYi
 * @create 2019/7/10
 * @since 1.0.0
 */
package com.ljy.system.marvel_sys.common.util.md5;

import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

public class Md5Util {

    /**
     * 用于用户注册密码加密
     * @param userName  盐值
     * @param psw  明文密码
     * @return
     */
    public static String md5Password(String psw,String userName){
        String hashAlgorithmName = "MD5";
        // 明文
        Object credentials = psw;
        // 盐值
        Object salt = ByteSource.Util.bytes(userName);
        // 加密次数
        int hashIterations = 1024;
        //进行加密
        Object result = new SimpleHash(hashAlgorithmName, credentials, salt, hashIterations);
        return result.toString();
    }

}
